package com.shiningstars.general;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;

import android.annotation.SuppressLint;

@SuppressLint("SimpleDateFormat")
public class StringDateComparator implements Comparator<String> {

	DateFormat df = new SimpleDateFormat("dd - MMM - yyyy");

	@Override
	public int compare(String str1, String str2) {
		try {
			Date date1 = df.parse(str1);
			Date date2 = df.parse(str2);

			if (date1.equals(date2)) {
				return 0;
			} else if (date1.before(date2)) {
				return 1;
			} else if (date1.after(date2)) {
				return -1;
			}

		} catch (Exception e) {
			e.printStackTrace();
		}

		return 0;
	}
}